<template>
  <div>
    <!-- 轮播图组件 -->
    <Carousel/>

    <br />
    <!-- 文章列表组件 -->
    <ActionList :list="list" :totol="totol" :currentPage="currentPage" />
  </div>
</template>

<script>
import ActionList from "../components/ActionList/inedx";
import Carousel from '../components/Carousel/index';

export default {
  layout: "default",
  components: {
    ActionList: ActionList,
    Carousel: Carousel
  },

  // 服务器获取文章列表数据传递给子组件
  async asyncData({ $axios, route, params, app }) {
    if ((route.fullPath == "/") | (route.query.page == 1)) {
      let { data } = await $axios({
        url: `http://59.110.217.14:3002/actionList?page=${1}`,
      });
      return { list: data.data, totol: data.totol, currentPage: 1 };
    } else {
      let { data } = await $axios({
        url: `http://59.110.217.14:3002/actionList?page=${route.query.page}`,
      });
      return {
        list: data.data,
        totol: data.totol,
        currentPage: Number(route.query.page),
      };
    }
  },
};
</script>

<style scoped lang="less">
</style>
